package top.jfunc.common.utils;

import java.lang.management.ManagementFactory;

public class ProcessUtil {
    private ProcessUtil() {
    }

    /**
     * 获取启动进程的用户
     * @return 启动进程的用户名
     */
    public static String getProcessStartedBy(){
        return System.getProperty("user.name");
    }

    public static String getPid(){
        try {
            String jvmName = ManagementFactory.getRuntimeMXBean().getName();
            return jvmName.split("@")[0];
        } catch (Exception e) {
            return null;
        }
    }
}
